package com.dq.vo.baseVo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public interface VO {
    interface ToVO {
        default VO toVO() {
            return toVO(false);
        }

        VO toVO(boolean isRecursion);
    }

    static Collection<? extends VO> toVOCollection(Iterable<? extends ToVO> vos) {
        return toVOCollection(vos, false);
    }

    static Collection<? extends VO> toVOCollection(Iterable<? extends ToVO> vos, boolean isRecursion) {
        List<VO> r = new ArrayList<>(); // collection
        if (null != vos) {
            vos.forEach(vo -> r.add(vo.toVO(isRecursion)));
        }
        return r;
    }

    static VO inCaseNull(VO.ToVO vo, boolean isRecursion) {
        return null == vo ? null : vo.toVO(isRecursion);
    }
}
